package org.kaindorf.kainflix.metadata.service;

import java.util.List;
import org.kaindorf.kainflix.metadata.exceptions.ResourceNotFoundException;
import org.kaindorf.kainflix.metadata.exceptions.IllegalDataGivenException;
import org.kaindorf.kainflix.metadata.repository.entity.Metadata;

public interface MetaDataService {
    
    /**
     * Saves the new meta data.
     * @param metaData
     * @return the MetaData bound to the persistence context
     * @throws IllegalDataGivenException when the entity is not valid
     */
    public Metadata saveMetaData(Metadata metaData);
    
    /**
     * Updates the meta data by replacing it with the given one.
     * @param metaData
     * @return the MetaData bound to the persistence context
     * @throws ResourceNotFoundException when the specified meta data could not be found
     */
    public Metadata updateMetaData(Metadata metaData);
    
    /**
     * Retrieves the meta data with the given id.
     * @param metaDataId
     * @return the requested meta data, never null
     * @throws ResourceNotFoundException when the specified meta data could not be found
     */
    public Metadata getMetaDataById(long metaDataId);
    
    /**
     * Retrieves all metadata.
     * @return all metadata
     * @throws ResourceNotFoundException when the specified metadata could not be found
     */
    public Iterable<Metadata> getAllMetaData();
    
    /**
     * Retrieves all metadata for the given productId.
     * @param productId the productId to be filtered for
     * @return all meta data
     * @throws ResourceNotFoundException when the specified meta data could not be found
     */
    public List<Metadata> getAllMetaDataWithProductId(Long productId);
    
    /**
     * Deletes the meta data with the given ID.
     * @param metaDataId
     * @throws ResourceNotFoundException when the specified meta data could not be found
     */
    public void delete(long metaDataId);
}
